package com.fwmagic.redis;

import redis.clients.jedis.Jedis;

import java.util.List;

public class ListValue {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.62.131", 6379, 5000);
        //从前面插入，插入结果：爬山，游泳，篮球
        jedis.lpush("hobby","篮球","游泳","爬山");

        //从后面插入，插入结果：1，2，3
        jedis.rpush("nums","1","2","3");

        //获取数据
        List<String> hobby = jedis.lrange("hobby", 0, -1);
        List<String> nums = jedis.lrange("nums", 0, -1);

        hobby.forEach(System.out::println);
        System.out.println("--------------");
        nums.forEach(System.out::println);

        //弹栈，取数，取出并删除,一次弹一个
        String hobby1 = jedis.lpop("hobby");
        System.out.println(hobby1);

        jedis.close();
    }
}
